import { createRouter, createWebHistory } from 'vue-router'
import HomePage from '@/pages/HomePage.vue'
import UserLoginPage from '@/pages/user/UserLoginPage.vue'
import UserRegisterPage from '@/pages/user/UserRegisterPage.vue'
import UserManagePage from '@/pages/admin/UserManagePage.vue'
import ACCESS_ENUM from '@/access/accessEnum'
import AddNotePage from '@/pages/user/AddNotePage.vue'
import NotesManagePage from '@/pages/admin/NotesManagePage.vue'
import NoteDetailPage from '@/pages/NoteDetailPage.vue'
import NoAuthPage from '@/pages/NoAuthPage.vue'
import CategoriesManagePage from '@/pages/admin/CategoriesManagePage.vue'
import MyNotesPage from '@/pages/user/MyNotesPage.vue'
import UserProfilePage from '@/pages/user/UserProfilePage.vue'

export const routes = [
  {
    path: '/',
    name: '主页',
    component: HomePage,
  },
  {
    path: '/user/login',
    name: '用户登录',
    component: UserLoginPage,
  },
  {
    path: '/user/register',
    name: '用户注册',
    component: UserRegisterPage,
  },
  {
    path: '/user/myNotes',
    name: '我的笔记',
    component: MyNotesPage,
    meta: {
      access: ACCESS_ENUM.USER,
    },
  },
  {
    path: '/user/profile',
    name: '个人资料',
    component: UserProfilePage,
    meta: {
      access: ACCESS_ENUM.USER,
    },
  },
  {
    path: '/admin/userManage',
    name: '用户管理',
    component: UserManagePage,
    meta: {
      access: ACCESS_ENUM.ADMIN,
    },
  },
  {
    path: '/addNote',
    name: '创建笔记',
    component: AddNotePage,
    meta: {
      access: ACCESS_ENUM.USER,
    },
  },
  {
    path: '/admin/noteManage',
    name: '笔记管理',
    component: NotesManagePage,
    meta: {
      access: ACCESS_ENUM.ADMIN,
    },
  },
  {
    path: '/admin/categoryManage',
    name: '分类管理',
    component: CategoriesManagePage,
    meta: {
      access: ACCESS_ENUM.ADMIN,
    },
  },
  {
    path: '/note/:id',
    name: '笔记详情',
    component: NoteDetailPage,
    props: true,
  },
  {
    path: '/noAuth',
    name: '无权限',
    component: NoAuthPage,
  },
]

const router = createRouter({
  history: createWebHistory(import.meta.env.BASE_URL),
  routes,
})

export default router
